package my;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class ImgUploadServer {

	public static void main(String[] args) throws IOException {
		ServerSocket ss = new ServerSocket(8890);
		while(true){
			Socket socket = ss.accept();
			BufferedInputStream bis = new BufferedInputStream(socket.getInputStream());
			BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("D:\\a.jpg"));
			int len = 0;
			byte[] bytes = new byte[1024];
			while((len = bis.read(bytes)) != -1){
				bos.write(bytes,0,len);
				bos.flush();
			}
			bos.close();
			socket.close();
		}

	}

}
